package com.xiaoming.e3mall.controller;

import com.xiaoming.e3mall.common.pojo.EasyUITreeNode;
import com.xiaoming.e3mall.service.ItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 商品分类管理
 */
@Controller
public class ItemCatController {

    @Autowired
    private ItemCatService itemCatService;

    /**
     * 加载商品分类的树的节点(商品添加)
     */

    @RequestMapping("/item/cat/list")
    @ResponseBody
    private List<EasyUITreeNode> getItemCatList(
            @RequestParam(name = "id", defaultValue = "0") Long parentId) {
        //页面传过来的是固定参数id 并且第一次传过来的时候没有参数 我们自己加载最高等级的父节点

        //调用服务,执行查询
        return itemCatService.getCategoryList(parentId);
    }

}
